//固定栏效果
var rights=document.querySelector('.fixed').children;
var fixop=rights[0];
var poption=rights[1];
var fixlis=fixop.children[0].children;
var poptionlis=poption.children;
for(let i=0;i<fixlis.length-1;i++){
   fixlis[i].index=i;
   fixlis[i].addEventListener('mouseover',function(){
      poption.className="poption";
      for(let j=0;j<poptionlis.length;j++){
         fixlis[j].className="";
         poptionlis[j].style.display="none";
      }
      poptionlis[this.index].style.top+=60*i+'px';
      poptionlis[this.index].style.display='block';
   })
}
fixop.addEventListener('mouseout',function(){
   poption.className='poption hide'
})
poption.addEventListener('mouseout',function(){
   poption.className='poption hide'
})
//回到顶部效果
$(fixlis[4]).on('click',function(){
$('body,html').animate({
   scrollTop:0,
},300)
});
//跳转至详情页
$('.shop .item .item-list').on('click',function(){
   location.assign('details.html')
})
//列表页数据接口
$(function(){
   // 提取地址栏上的参数
   let categoryId = getParam('id');
   $.get(baseUrl+'/goods/lists',{categoryId},(res)=>{
       console.log(res);
       let html = '';
       res.data.forEach((item,index)=>{
           html+=`<div class="item-list">
           <div class="img"><img src="${item.goodsImg}" alt=""></div>
           <div class="cont">
              <p>${item.goodsName}</p>
              <p>￥249</p>
           </div>
        </div>`;
       })
       $('.item').html(html);
   },'json')
})